
 <!DOCTYPE HTML>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  
    <title>【刷题】1. 链表 | 梭哈如疯</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="Andy">
    

    
    <meta name="description" content="基础题 递归: 合并两个有序链表 递归解法 1234567891011def mergeTwoLists(self, l1, l2):      if not l1:          return l2      if not l2:          return l1      if l1.val &lt;&#x3D; l2.val:          l1.next &#x3D; self.mergeTwoL">
<meta property="og:type" content="article">
<meta property="og:title" content="【刷题】1. 链表">
<meta property="og:url" content="https://be_patient.gitee.io/bigorhome/2021/03/09/%E3%80%90%E5%88%B7%E9%A2%98%E3%80%911-%E9%93%BE%E8%A1%A8/index.html">
<meta property="og:site_name" content="梭哈如疯">
<meta property="og:description" content="基础题 递归: 合并两个有序链表 递归解法 1234567891011def mergeTwoLists(self, l1, l2):      if not l1:          return l2      if not l2:          return l1      if l1.val &lt;&#x3D; l2.val:          l1.next &#x3D; self.mergeTwoL">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-03-09T14:01:00.000Z">
<meta property="article:modified_time" content="2021-03-10T15:02:40.999Z">
<meta property="article:author" content="Andy">
<meta property="article:tag" content="刷题">
<meta property="article:tag" content="链表">
<meta name="twitter:card" content="summary">

    
    
    <link rel="icon" href="/bigorhome/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/bigorhome/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/bigorhome/img/jacman.jpg">
    
    
<link rel="stylesheet" href="/bigorhome/css/style.css">
<link rel="stylesheet" href="/bigorhome/%02.css">
<link rel="stylesheet" href="/bigorhome/.css">

<meta name="generator" content="Hexo 5.4.0"></head>

  <body>
    <header>
      
<div>
		
			<div id="textlogo">
				<h1 class="site-name"><a href="/bigorhome/" title="梭哈如疯">梭哈如疯</a></h1>
				<h2 class="blog-motto">周期终将幻灭，轮回才是永恒</h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜单">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/bigorhome/">首页</a></li>
					
						<li><a href="/bigorhome/archives">归档</a></li>
					
						<li><a href="/bigorhome/about">关于</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="搜索" />
						<input type="hidden" name="q" value="site:be_patient.gitee.io/bigorhome">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/bigorhome/2021/03/09/【刷题】1-链表/" title="【刷题】1. 链表" itemprop="url">【刷题】1. 链表</a>
  </h1>
  <p class="article-author">By
       
		<a href="/bigorhome/about" title="Andy" target="_blank" itemprop="author">Andy</a>
		
  <p class="article-time">
    <time datetime="2021-03-09T14:01:00.000Z" itemprop="datePublished"> 发表于 2021-03-09</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目录</strong>
		
			<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9F%BA%E7%A1%80%E9%A2%98"><span class="toc-number">1.</span> <span class="toc-text">基础题</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%80%92%E5%BD%92%EF%BC%9A%E4%B8%A4%E4%B8%A4%E4%BA%A4%E6%8D%A2%E8%8A%82%E7%82%B9"><span class="toc-number">1.1.</span> <span class="toc-text">递归：两两交换节点</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%8C%E6%8C%87%E9%92%88"><span class="toc-number">2.</span> <span class="toc-text">双指针</span></a></li></ol>
		
		</div>
		
		<h1 id="基础题"><a href="#基础题" class="headerlink" title="基础题"></a>基础题</h1><ol>
<li>递归: <a target="_blank" rel="noopener" href="https://leetcode-cn.com/problems/merge-two-sorted-lists/submissions/">合并两个有序链表</a><details>
<summary>递归解法</summary>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">mergeTwoLists</span>(<span class="params">self, l1, l2</span>):</span></span><br><span class="line">      <span class="keyword">if</span> <span class="keyword">not</span> l1:</span><br><span class="line">          <span class="keyword">return</span> l2</span><br><span class="line">      <span class="keyword">if</span> <span class="keyword">not</span> l2:</span><br><span class="line">          <span class="keyword">return</span> l1</span><br><span class="line">      <span class="keyword">if</span> l1.val &lt;= l2.val:</span><br><span class="line">          l1.<span class="built_in">next</span> = self.mergeTwoLists(l1.<span class="built_in">next</span>, l2)</span><br><span class="line">          <span class="keyword">return</span> l1</span><br><span class="line">      <span class="keyword">else</span>:</span><br><span class="line">          l2.<span class="built_in">next</span> = self.mergeTwoLists(l1, l2.<span class="built_in">next</span>)</span><br><span class="line">          <span class="keyword">return</span> l2</span><br></pre></td></tr></table></figure>
</details>
<details>
<summary>迭代解法</summary>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>(<span class="params"><span class="built_in">object</span></span>):</span></span><br><span class="line">  <span class="function"><span class="keyword">def</span> <span class="title">mergeTwoLists</span>(<span class="params">self, l1, l2</span>):</span></span><br><span class="line">      head = ListNode()</span><br><span class="line">      new = head</span><br><span class="line">      <span class="keyword">while</span> l1 <span class="keyword">and</span> l2:</span><br><span class="line">          <span class="keyword">if</span> l1.val &lt;= l2.val:</span><br><span class="line">              head.<span class="built_in">next</span> = l1</span><br><span class="line">              l1 = l1.<span class="built_in">next</span></span><br><span class="line">          <span class="keyword">else</span>:</span><br><span class="line">              head.<span class="built_in">next</span> = l2</span><br><span class="line">              l2 = l2.<span class="built_in">next</span></span><br><span class="line">          head = head.<span class="built_in">next</span></span><br><span class="line">      head.<span class="built_in">next</span> = l1 <span class="keyword">if</span> l1 <span class="keyword">else</span> l2</span><br><span class="line">      <span class="keyword">return</span> new.<span class="built_in">next</span></span><br></pre></td></tr></table></figure>
</details></li>
<li>基础: <a target="_blank" rel="noopener" href="https://leetcode-cn.com/problems/rotate-list/">旋转列表</a><ul>
<li>先找到原尾部和长度；</li>
<li>链接成环；</li>
<li>找到新的头部和尾部，断开。</li>
<li><details>
<summary>按照描述解</summary>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>(<span class="params"><span class="built_in">object</span></span>):</span></span><br><span class="line">  <span class="function"><span class="keyword">def</span> <span class="title">rotateRight</span>(<span class="params">self, head, k</span>):</span></span><br><span class="line">      <span class="keyword">if</span> <span class="keyword">not</span> head:</span><br><span class="line">          <span class="keyword">return</span> <span class="literal">None</span></span><br><span class="line">      <span class="keyword">if</span> <span class="keyword">not</span> head.<span class="built_in">next</span>:</span><br><span class="line">          <span class="keyword">return</span> head</span><br><span class="line">      <span class="comment"># 先找到最尾部和长度</span></span><br><span class="line">      old_tail = head</span><br><span class="line">      length = <span class="number">1</span></span><br><span class="line">      <span class="keyword">while</span> old_tail.<span class="built_in">next</span>:</span><br><span class="line">          old_tail = old_tail.<span class="built_in">next</span></span><br><span class="line">          length += <span class="number">1</span></span><br><span class="line">      old_tail.<span class="built_in">next</span> = head <span class="comment"># 环起来</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 找到新的头和尾</span></span><br><span class="line">      new_tail = head</span><br><span class="line">      <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(length - k % length - <span class="number">1</span>):</span><br><span class="line">          new_tail = new_tail.<span class="built_in">next</span></span><br><span class="line">      new_head = new_tail.<span class="built_in">next</span></span><br><span class="line">      new_tail.<span class="built_in">next</span> = <span class="literal">None</span></span><br><span class="line">      <span class="keyword">return</span> new_head</span><br></pre></td></tr></table></figure>
</details></li>
</ul>
</li>
<li><h2 id="递归：两两交换节点"><a href="#递归：两两交换节点" class="headerlink" title="递归：两两交换节点"></a>递归：<a target="_blank" rel="noopener" href="https://leetcode-cn.com/problems/swap-nodes-in-pairs/">两两交换节点</a></h2><details>
<summary>Python解法</summary>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span>(<span class="params"><span class="built_in">object</span></span>):</span></span><br><span class="line">  <span class="function"><span class="keyword">def</span> <span class="title">swapPairs</span>(<span class="params">self, head</span>):</span></span><br><span class="line">      <span class="keyword">if</span> <span class="keyword">not</span> head <span class="keyword">or</span> <span class="keyword">not</span> head.<span class="built_in">next</span>:</span><br><span class="line">          <span class="keyword">return</span> head</span><br><span class="line">      new_head = head.<span class="built_in">next</span></span><br><span class="line">      head.<span class="built_in">next</span> = self.swapPairs(new_head.<span class="built_in">next</span>)</span><br><span class="line">      new_head.<span class="built_in">next</span> = head</span><br><span class="line">      <span class="keyword">return</span> new_head</span><br></pre></td></tr></table></figure>
</details></li>
</ol>
<h1 id="双指针"><a href="#双指针" class="headerlink" title="双指针"></a>双指针</h1><ol>
<li><a target="_blank" rel="noopener" href="https://leetcode-cn.com/problems/kth-node-from-end-of-list-lcci/">实现一种算法，找出单向链表中倒数第 k 个节点。返回该节点的值。</a><details>
<summary>Python解法</summary>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">kthToLast</span>(<span class="params">self, head, k</span>):</span></span><br><span class="line">    fast, slow = head, head</span><br><span class="line">    <span class="keyword">while</span> fast:</span><br><span class="line">        <span class="keyword">if</span> k != <span class="number">0</span>:</span><br><span class="line">            k -= <span class="number">1</span></span><br><span class="line">            fast = fast.<span class="built_in">next</span></span><br><span class="line">        fast = fast.<span class="built_in">next</span></span><br><span class="line">        slow = slow.<span class="built_in">next</span></span><br><span class="line">    <span class="keyword">return</span> slow.val</span><br></pre></td></tr></table></figure>
<\details></li>
<li><a target="_blank" rel="noopener" href="https://leetcode-cn.com/problems/rotate-list/">给定一个链表，旋转链表，将链表每个节点向右移动 k 个位置，其中 k 是非负数。</a><details>
<summary>Python解法</summary>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">形成环，尾结点移动 <span class="built_in">len</span> - k步，找到头结点断开环</span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">rotateRight</span>(<span class="params">self, head, k</span>):</span></span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    :type head: ListNode</span></span><br><span class="line"><span class="string">    :type k: int</span></span><br><span class="line"><span class="string">    :rtype: ListNode</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line">    <span class="keyword">if</span> <span class="keyword">not</span> head:</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">None</span></span><br><span class="line">    <span class="keyword">if</span> <span class="keyword">not</span> head.<span class="built_in">next</span>:</span><br><span class="line">        <span class="keyword">return</span> head</span><br><span class="line">    old_tail = head</span><br><span class="line">    length = <span class="number">1</span></span><br><span class="line">    <span class="keyword">while</span> old_tail.<span class="built_in">next</span>:</span><br><span class="line">        old_tail = old_tail.<span class="built_in">next</span></span><br><span class="line">        length += <span class="number">1</span></span><br><span class="line">    old_tail.<span class="built_in">next</span> = head</span><br><span class="line">    new_tail = head</span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(length - k % length - <span class="number">1</span>):</span><br><span class="line">        new_tail = new_tail.<span class="built_in">next</span></span><br><span class="line">    new_head = new_tail.<span class="built_in">next</span></span><br><span class="line">    new_tail.<span class="built_in">next</span> = <span class="literal">None</span></span><br><span class="line">    <span class="keyword">return</span> new_head</span><br></pre></td></tr></table></figure>
 <\details></li>
</ol>
  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">

<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/bigorhome/categories/%E5%88%B7%E9%A2%98/">刷题</a>
</div>


  <div class="article-tags">
  
  <span></span> <a href="/bigorhome/tags/刷题/">刷题</a><a href="/bigorhome/tags/链表/">链表</a>
  </div>

</div>



	<div class="article-share" id="share">
	
	  <div data-url="https://be_patient.gitee.io/bigorhome/2021/03/09/%E3%80%90%E5%88%B7%E9%A2%98%E3%80%911-%E9%93%BE%E8%A1%A8/" data-title="【刷题】1. 链表 | 梭哈如疯" data-tsina="" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/bigorhome/2021/03/10/【BTC复盘记录20210310】B浪反弹预计为做顶形态/" title="【BTC复盘记录20210310】B浪反弹预计为做顶形态">
  <strong>上一篇：</strong><br/>
  <span>
  【BTC复盘记录20210310】B浪反弹预计为做顶形态</span>
</a>
</div>


<div class="next">
<a href="/bigorhome/2021/03/09/【台大机器学习陈蕴侬】1.机器学习和深度学习概述/"  title="【台大机器学习-陈蕴侬】1. 机器学习和深度学习概述">
 <strong>下一篇：</strong><br/> 
 <span>【台大机器学习-陈蕴侬】1. 机器学习和深度学习概述
</span>
</a>
</div>

</nav>

	



</div>  
      <div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目录</strong>
 
 <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9F%BA%E7%A1%80%E9%A2%98"><span class="toc-number">1.</span> <span class="toc-text">基础题</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%80%92%E5%BD%92%EF%BC%9A%E4%B8%A4%E4%B8%A4%E4%BA%A4%E6%8D%A2%E8%8A%82%E7%82%B9"><span class="toc-number">1.1.</span> <span class="toc-text">递归：两两交换节点</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%8C%E6%8C%87%E9%92%88"><span class="toc-number">2.</span> <span class="toc-text">双指针</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div>
<aside class="clearfix">

  


  
<div class="categorieslist">
	<p class="asidetitle">分类</p>
		<ul>
		
		  
			<li><a href="/bigorhome/categories/刷题/" title="刷题">刷题<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/bigorhome/categories/数字货币/" title="数字货币">数字货币<sup>2</sup></a></li>
		  
		
		  
			<li><a href="/bigorhome/categories/机器学习/" title="机器学习">机器学习<sup>1</sup></a></li>
		  
		
		</ul>
</div>


  
<div class="tagslist">
	<p class="asidetitle">标签</p>
		<ul class="clearfix">
		
			
				<li><a href="/bigorhome/tags/BTC/" title="BTC">BTC<sup>2</sup></a></li>
			
		
			
				<li><a href="/bigorhome/tags/每日复盘/" title="每日复盘">每日复盘<sup>2</sup></a></li>
			
		
			
				<li><a href="/bigorhome/tags/陈蕴侬/" title="陈蕴侬">陈蕴侬<sup>1</sup></a></li>
			
		
			
				<li><a href="/bigorhome/tags/机器学习/" title="机器学习">机器学习<sup>1</sup></a></li>
			
		
			
				<li><a href="/bigorhome/tags/深度学习/" title="深度学习">深度学习<sup>1</sup></a></li>
			
		
			
				<li><a href="/bigorhome/tags/刷题/" title="刷题">刷题<sup>1</sup></a></li>
			
		
			
				<li><a href="/bigorhome/tags/链表/" title="链表">链表<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="linkslist">
  <p class="asidetitle">友情链接</p>
    <ul>
        
    </ul>
</div>

</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Go Big or Go Home <br/>
			</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		
		
		
		
		
		
		
		
		
		<a href="mailto:andy8023heart@gmail.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2021 
		
		<a href="/bigorhome/about" target="_blank" title="Andy">Andy</a>
		
		
		</p>
</div>
</footer>
    <script src="/bigorhome/js/jquery-2.0.3.min.js"></script>
<script src="/bigorhome/js/jquery.imagesloaded.min.js"></script>
<script src="/bigorhome/js/gallery.js"></script>
<script src="/bigorhome/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>











<link rel="stylesheet" href="/bigorhome/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/bigorhome/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?f0c38645948c5e7ed17b6230ad305653";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="返回顶部"><img src="/bigorhome/img/scrollup.png"/></a>
	</div>
	<script src="/bigorhome/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
